package characterCreator;

import java.util.Random;

public class Character {
	
	private String name;
	private String player;
	private ClassType type;
	private Alignment alignment;
	private Sex sex;
	private Abilities[] primeRequisite;
	private int str, strADJ, inte, inteADJ, wis, wisADJ, dex, dexADJ, con, conADJ, cha, chaADJ, ac, hp, exp, expBonus, 
				THAC0, svPoison, svMagicWand,svParalysis,svDragon,
				svSpell;
	
	protected int 	level;
	
	public Character() {
		this.name = "";
		this.player = "";
		this.type = ClassType.Fighter;
		this.alignment = Alignment.Lawful;
		this.sex = Sex.Male;
		this.level = 0;
		this.primeRequisite = new Abilities[2];
		this.primeRequisite[0] = Abilities.Strength;
		this.primeRequisite[1] = null;
		this.str = 0;
		this.inte = 0;
		this.wis = 0;
		this.dex = 0;
		this.con = 0;
		this.cha = 0;
		this.ac = 0;
		this.hp = 0;
		this.exp = 0;
		this.expBonus = 0;
		this.THAC0 = 0;
		this.svPoison = 0;
		this.svMagicWand = 0;
		this.svParalysis = 0;
		this.svDragon = 0;
		this.svSpell = 0;
	}
	
	public String getName() 				{ return this.name; }
	public String getPlayer()	 			{ return this.player; }
	public ClassType getType()				{ return this.type; }
	public Alignment getAlignment() 		{ return this.alignment; }
	public Sex getSex() 					{ return this.sex; }
	public int getLevel() 					{ return this.level; }
	public int getAC() 						{ return this.ac; }
	public int getHP() 						{ return this.hp; }
	public int getExp() 					{ return this.exp; }
	public int getExpBonus() 				{ return this.expBonus; }
	public int getTHAC0()					{ return this.THAC0; }
	
	public Abilities getPrimeRequisite()	{ 
		return getPrimeRequisite(0);
		}
	public Abilities getPrimeRequisite(int i) {
		return primeRequisite[i];
	}
	
	public int getSave(SavingThrow type) { 
		int value = -1;
		switch (type) {
		case svPoison: 
			value = this.svPoison;
			break;
		case svMagicWand:
			value = this.svMagicWand;
			break;
		case svParalysis:
			value = this.svParalysis;
			break;
		case svDragon:
			value = this.svDragon;
			break;
		case svSpell:
			value = this.svSpell;
			break;
		}
		return value;
	}

	public int  getAbility(Abilities type) {
		int value = -1;
		switch (type) {
		case Strength: 
			value = this.str;
			break;
		case Intelligence:
			value = this.inte;
			break;
		case Wisdom:
			value = this.wis;
			break;
		case Dexterity:
			value = this.dex;
			break;
		case Constitution:
			value = this.con;
			break;
		case Charisma:
			value = this.cha;
			break;
		}
		return value;
	}
	
	public int  getAbilityADJ(Abilities type) {
		int value = -1;
		switch (type) {
		case Strength: 
			value = this.strADJ;
			break;
		case Intelligence:
			value = this.inteADJ;
			break;
		case Wisdom:
			value = this.wisADJ;
			break;
		case Dexterity:
			value = this.dexADJ;
			break;
		case Constitution:
			value = this.conADJ;
			break;
		case Charisma:
			value = this.chaADJ;
			break;
		}
		return value;
	}

	public void setName(String name)			{ this.name = name; }
	public void setPlayer(String player)		{ this.player = player; }
	public void setType(ClassType type)			{ this.type = type; }
	public void setAlignment(Alignment type) 	{ this.alignment = type; }
	public void setSex(Sex type)				{ this.sex = type;}
	public void setLevel(int level)				{ this.level = level; }
	public void setAC(int ac)					{ this.ac = ac; }
	public void setHP(int hp)					{ this.hp = hp; }
	public void setExp(int exp)					{ this.exp = exp; }
	public void setTHAC0(int THAC0)				{ this.THAC0 = THAC0; }
	
	public void setPrimeRequisite(Abilities a,int i) 	{ 
		this.primeRequisite[i] = a; 
		System.out.println("PR set: " + a + " to: " + this.primeRequisite[i]);
		}
	
	public void setExpBonus()		{ 
		int prScore = this.getAbility(this.getPrimeRequisite());
		if (prScore < 13) {
			this.expBonus = 0;
		} else if (prScore <= 15) {
			this.expBonus = 5;
		} else if (prScore <= 18) {
			this.expBonus = 10;
		}
	}
	
	public void setSave(SavingThrow type, int value) { 
		switch (type) {
		case svPoison: 
			this.svPoison = value;
			break;
		case svMagicWand:
			this.svMagicWand = value;
			break;
		case svParalysis:
			this.svParalysis = value;
			break;
		case svDragon:
			this.svDragon = value;
			break;
		case svSpell:
			this.svSpell = value;
			break;
		}
	}
	
	public void setAbility(Abilities type, int value) {
		switch (type) {
		case Strength: 
			this.str = value;
			break;
		case Intelligence:
			this.inte = value;
			break;
		case Wisdom:
			this.wis = value;
			break;
		case Dexterity:
			this.dex = value;
			break;
		case Constitution:
			this.con = value;
			break;
		case Charisma:
			this.cha = value;
			break;
		}
		setAdjustment(type);
	}
	
	public void setAdjustment(Abilities type) {
		switch (type) {
		case Strength:
			this.strADJ = new Die().calcAdjustment(this.str);
			break;
		case Intelligence:
			this.inteADJ = new Die().calcAdjustment(this.inte);
			break;
		case Wisdom:
			this.wisADJ = new Die().calcAdjustment(this.wis);
			break;
		case Dexterity:
			this.dexADJ = new Die().calcAdjustment(this.dex);
			break;
		case Constitution:
			this.conADJ = new Die().calcAdjustment(this.con);
			break;
		case Charisma:
			this.chaADJ = new Die().calcAdjustment(this.cha);
			break;
		}
	}
	
	
	public void display() {
		System.out.println(this.player);
		System.out.println("\tCharacter Name: " + this.name + "\t\tSex: " + this.sex);
		System.out.println("\t\tClass: " + this.type + "\t\tLevel: " + this.level + "\t\tAlignment: " 
				+ this.alignment);
		
		System.out.println("\t\t\tXP: " + this.exp + "\t\thp: " + this.hp);
		System.out.println("\t\t\tStr: " + this.str + 
							"\t\tDeath Ray, Poison: " + this.svPoison);
		System.out.println("\t\t\tInt: " + this.inte + 
							"\t\tMagic Wands: " + this.svMagicWand);
		System.out.println("\t\t\tWis: " + this.wis + 
							"\t\tParalysis: " + this.svParalysis);
		System.out.println("\t\t\tDex: " + this.dex + 
							"\t\tDragon Breath: " + this.svDragon);
		System.out.println("\t\t\tCon: " + this.con + 
							"\t\tRod, Staff, or Spell: " + this.svSpell);
		System.out.println("\t\t\tCha: " + this.cha);
		
		System.out.println("\t\tAC: " + this.ac);
		
	}
	
}
